

#pragma once

#include "NetworkActionBase.hpp"
#include <functional>

CYBERTRON_BEGIN

class NetworkActionLambda : public NetworkActionBase
{
public:
	CybertronCoreAPI NetworkActionLambda();
	CybertronCoreAPI virtual ~NetworkActionLambda();

	CybertronCoreAPI void setFuncOnStart(std::function<void()> funcOnStart);
	CybertronCoreAPI void setFuncOnTimer(std::function<void(int)> funcOnTimer);
	CybertronCoreAPI void setFuncOnTimeout(std::function<void()> funcOnTimeout);
	CybertronCoreAPI void setFuncOnMessage(std::function<void(Message&)> funcOnMessage);
	CybertronCoreAPI void setFuncOnDesiredMessage(std::function<void(Message&)> funcOnDesiredMessage);
	CybertronCoreAPI void setFuncOnEnd(std::function<void()> funcOnEnd);

protected:
	CybertronCoreAPI virtual void onStart();
	CybertronCoreAPI virtual void onTimer(int ms);
	CybertronCoreAPI virtual void onTimeout();
	CybertronCoreAPI virtual void onDesiredMessage(Message& msg);
	CybertronCoreAPI virtual void onMessage(Message& msg);
	CybertronCoreAPI virtual void onEnd();

private:
	std::function<void()> mFuncOnStart;
	std::function<void(int)> mFuncOnTimer;
	std::function<void()> mFuncOnTimeout;
	std::function<void(Message&)> mFuncOnMessage;
	std::function<void(Message&)> mFuncOnDesiredMessage;
	std::function<void()> mFuncOnEnd;
};

CYBERTRON_END
